﻿#include "handler.h"

Handler::Handler(QObject *parent) : QObject(parent)
{
    watcher=new QFutureWatcher<bool>(this);
    connect(watcher,SIGNAL(finished()),this,SLOT(scanFinished()));
}

void Handler::scan(const QString &dbName)
{
    qDebug() <<"Scan Processing ......";
    QFileInfoList drives=QDir::drives();
    time.start();
    QFuture<bool> future=QtConcurrent::run(sp_scanDrivers,drives,dbName);
    // future.waitForFinished();
    watcher->setFuture(future);
}

void Handler::scanFinished()
{
    qDebug() << "Scan Finished" << endl
             << "Time Used :" << time.elapsed() << "ms";
    QCoreApplication::quit();
}
